package cn.huoyingkeji.system.mapper;

import com.github.yulichang.base.MPJBaseMapper;

import cn.huoyingkeji.system.entity.SysRoleResourceRelation;

import java.util.Collection;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SysRoleResouceRelationMapper extends MPJBaseMapper<SysRoleResourceRelation> {

    @Delete(
        "<script>"
       +"    delete from t_sys_role_resource_relation where role_id=#{roleId}"
       +"</script>"
    )
    Integer delByRoleId(Long roleId);
    @Insert(
        "<script>"
        +"    insert into t_sys_role_resource_relation(role_id,resource_id,tenant_id) "
        +"    VALUES "
        +"    <foreach collection='relations' item='relation' index='index' separator=','>" + //
                        "            (#{relation.roleId}, #{relation.resourceId}, '000000')" + //
                        "        </foreach>"
        +"</script>"
    )
    Integer saveAll(Collection<SysRoleResourceRelation> relations);
}
